<template>
    <section id="course">
        <div class="article-container" @click="toDetail(articleInfo.idStr)">
            <div class="article-item">
                <img class="default-icon" :src="articleInfo.coverUrl" onerror="javascript:this.src='static/images/default-course.png'">
                <p class="content-item">
                    <span>{{ articleInfo.name }}</span>
                    <span>
                        <a>￥{{articleInfo.payPrice}}</a>
                        <img src="static/images/super-vip.png">
                    </span>
                </p>
                <p class="ready">
                    <img src="static/images/ready.png">
                    <a>{{ articleInfo.tags }}</a>
                </p>
                <p class="course-tags-container">
                    {{ articleInfo.coach }}教练 {{ articleInfo.duration }}分钟 {{ articleInfo.level }} {{ articleInfo.appliance }}器械
                </p>
            </div>
        </div>
    </section>
</template>
<script>
export default {
    name: 'Course',
    props: {
        articleInfo: {
            type: Object,
            default: function () {
                return {}
            }
        }
    },
    methods: {
        toDetail (id) {
            this.$router.push(`/coursedetail?id=${id}`)
        }
    }
}
</script>
<style lang="scss" scoped>
@mixin ellipsis{
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.article-container{
    margin: 0.2rem;
}
.article-item{
    width: 100%;
    border-radius: 2px;
    background: #fff;
    box-sizing: border-box;
    padding: 0.2rem 0.25rem;
    .default-icon{
        display: block;
        width: 6.6rem;
        height: 3.6rem;
        margin-bottom: 0.26rem;
    }
    p{
        position: relative;
    }
    span{
        display: inline-block;
    }
    span:nth-child(1){
        @include ellipsis;
        width: 4.2rem;
        font-size: 0.3rem;
        color: #333;
    }
    span:nth-child(2){
        color: #f85f1c;
        // width: 1.2rem;
        text-align: right;
        position: absolute;
        right: 0;
        top: -0.15rem;
        a{
            display: block;
        }
        img{
            display: block;
            width: 0.8rem;
            height: 0.24rem;
            float: right;
        }
    }
}
.content-item{
    margin-bottom: 0.1rem; 
}
.ready{
    width: 100%;
    @include ellipsis;
    margin-bottom: 0.3rem;
    color: #666;
    height: 0.34rem;
    line-height: 0.34rem;
    font-size: 0.24rem;
    img{
        display: inline-block;
        width: 0.96rem;
        height: 0.34rem;
        margin-right: 0.2rem;
    }
}
.course-tags-container{
    @include ellipsis;
    font-size: 0.22rem;
    color: #999;
}    
</style>
